<include file="Public:header" />
<include file="Public:logo" />
<include file="Public:menu" />
<include file="Public:table_br" />
<script>
$(function(){
    $('#user_name').focus();   //将焦点定位在原始密码框中user_pwd
    $('#tijiao').click(
        function(){
            var user_name=$('#user_name').val();
            var user_pwd=$('#user_pwd').val();
            var n_user_pwd=$('#n_user_pwd').val();
            var admin=$('#admin').val();
            
            //if(check(user_name,user_pwd,n_user_pwd))
               // {
                    $.post("{:U('manger/save_new_user')}",
                    {'user_name':user_name,
                        'user_pwd':user_pwd,
                        'n_user_pwd':n_user_pwd,
                        'admin':admin
                    },
                    function(data){chuli(data.status);},'json')
                //}
        })

        function chuli(status){
        switch(status)
        {
            case 0:   //有项目为空
                $('#pop').html('<font color="red">全部项目必修填写！请正确填写！</font>');
                $('#pop_user_name').html('<img src="__ROOT__/images/error.gif">');
                $('#user_name').focus();
                break;
            case 1:   //两次密码输入的不一致
                $('#pop').html('<font color="red">两次密码输入的不一致！</font>');
                $('#user_pwd').val('');
                $('#n_user_pwd').val('');
                $('#user_pwd').focus();
                break;
            case 2:   //添加成功
                $('#pop').html('<font color="red">新用户添加成功！！请牢记用户信息！</font>');
                $('#user_name').val('');
                $('#user_pwd').val('');
                $('#n_user_pwd').val('');
                $('#user_name').focus();
                break;
            case 3:  //系统错误
                $('#pop').html('<font color="red">系统发生错误！请刷新网页后重新添加新用户！</font>');
                $('#user_name').val('');
                $('#user_pwd').val('');
                $('#n_user_pwd').val('');
                $('#user_name').focus();
                break;
        }
    }

    function check(user_name,user_pwd,n_user_pwd)
    {
        if(user_name=='')
            {
               $('#pop').html('<font color="red">用户名必须填写！请正确填写用户名！</font>');
               $('#pop_user_name').html('<img src="__ROOT__/images/error.gif">');
               $('#user_name').focus();
               return false;
            }
        if(user_pwd=='')
            {
                $('#pop').html('<font color="red">密码必须填写！请正确填写密码！</font>');
                $('#pop_user_pwd').html('<img src="__ROOT__/images/error.gif">');
               $('#user_pwd').focus();
               return false;
            }
        if(n_user_pwd=='')
            {
                $('#pop').html('<font color="red">重复密码必须填写！请正确填写重复密码！</font>');
               $('#new_t_pop').html('<img src="__ROOT__/images/error.gif">');
               $('#t_user_pwd').focus();
               return false;
            }
        if(user_pwd!=n_user_pwd)
            {
                $('#pop').html('<font color="red">密码两次输入不一致，请确认后重新输入！</font>');
               $('#user_pwd').val('');
               $('#n_user_pwd').val('');
               $('#pop_user_pwd').html('<img src="__ROOT__/images/error.gif">');
               $('#pop_n_user_pwd').html('<img src="__ROOT__/images/error.gif">');
               $('#user_pwd').focus();
               return false;
            }
        return true;
    }

})



</script>
<tbody><center>
<table width="780" border="1" cellpadding="0" cellspacing="0" align="center" style="border-collapse:collapse" bordercolor="#000000">
<tr>
    <td width="15%" align="center" valign="top">
        <br>
        <include file="Manger:admin_menu" />
    </td>
    <td width="85%" valign="top">
        <a href="__APP__/manger.html">管理中心</a>-添加用户
        <br>
        <a id="pop"></a>
        <br>
        用&nbsp;户&nbsp;名：<input type="text" maxlength="15" id="user_name" value="" size="15"><a id="pop_user_name"></a>(最长为15位)<br>
        密&nbsp;&nbsp;&nbsp;&nbsp;码：<input type="password" id="user_pwd" maxlength="20" value="" size="15" /><a id="pop_user_pwd"></a>(密码最长为20位)<br>
        重复密码：<input type="password" id="n_user_pwd" maxlength="20" value="" size="15" /><a id="pop_n_user_pwd"></a><br>
        管理权限：<select id="admin">
            <option value="0" checked>否</option>
            <option value="1">是</option>
        </select>
        <br><br>
        &nbsp;&nbsp;&nbsp;&nbsp;<input type="button" id="tijiao" value="添 加">
    </td>
</tr>
</table>
</center></tbody>
<include file="Public:ender" />
